﻿using Kernel.IService.Service.Core;
using Kernel.Model.Core.CodeGenerator;

namespace WebAPI.Areas.Core.Controllers;

[ApiVersion("1.0")]
[AllowAnonymous]
public class CodeGeneratorController : CoreBaseController
{

    public ICodeGeneratorService codeSvc { get; set; }

    /// <summary>
    /// 生成模型层代码
    /// </summary>
    /// <param name="model">入参</param>
    /// <returns>代码路径</returns>
    [HttpGet]
    [Route("code"), MapToApiVersion("1.0")]
    public IActionResult GenerationModelCode_V1_0([FromQuery] CodeGeneratorInParams model)
    {
        model.Catalog = model.Catalog.Trim('/').Trim('\\');
        var codeFolder = codeSvc.Generation(model);
        var result = new CommandResult<string>() { Data = "生成成功！代码路径为：" + codeFolder };

        return Ok(result);
    }

}
